using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace AppToolKit.Core.Text
{
	public class StringUtils
	{
		public static bool IsChinaLetter(char chr)
		{
			int num = 19968;
			int num2 = 40869;
			return (int)chr >= num && (int)chr <= num2;
		}
		public static string Format(string format, IDictionary<string, string> dict)
		{
			string pattern = "\\$\\{(?<key>.*?)\\}";
			Regex regex = new Regex(pattern, RegexOptions.Compiled);
			return regex.Replace(format, delegate(Match match)
			{
				string result;
				if (match.Groups["key"].Success)
				{
					string value = match.Groups["key"].Value;
					if (!dict.ContainsKey(value))
					{
						throw new FormatException(string.Format("key({0})不包含在dict中", value));
					}
					result = dict[value];
				}
				else
				{
					result = string.Empty;
				}
				return result;
			}
			);
		}
		public static string Format(string format, IDictionary<string, object> dict)
		{
			string pattern = "\\$\\{(?<key>.*?)\\}";
			Regex regex = new Regex(pattern, RegexOptions.Compiled);
			return regex.Replace(format, delegate(Match match)
			{
				string result;
				if (match.Groups["key"].Success)
				{
					string value = match.Groups["key"].Value;
					if (!dict.ContainsKey(value))
					{
						throw new FormatException(string.Format("key({0})不包含在dict中", value));
					}
					result = dict[value].ToString();
				}
				else
				{
					result = string.Empty;
				}
				return result;
			}
			);
		}
	}
}
